package com.yjh.server.controller.miniapp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yjh.pojo.entity.CourtInfo;
import com.yjh.pojo.vo.R;
import com.yjh.server.service.CourtInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mini/courtInfo")
public class MiniCourtInfoController {
    @Autowired
    private CourtInfoService courtInfoService;

    @GetMapping("/getCourtInfoByCategoryId")
    public R<List> getCourtInfoByCategoryId(@RequestParam("id") Integer id){
        LambdaQueryWrapper<CourtInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(CourtInfo::getCategoryId,id);

        List<CourtInfo> list = courtInfoService.list(wrapper);

        return R.success(list);
    }

    @GetMapping("/getCourtInfoById")
    public R<CourtInfo> getCourtInfoById(@RequestParam("id") Integer id){
//        LambdaQueryWrapper<CourtInfo> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(CourtInfo::getCourtId,id);

        CourtInfo courtInfo = courtInfoService.getById(id);

        return R.success(courtInfo);
    }
}
